inherited fmStaffNeeddoc: TfmStaffNeeddoc
  Left = 377
  Top = 233
  Width = 749
  Height = 555
  Caption = #1064#1072#1073#1083#1086#1085#1099' '#1085#1077#1086#1073#1093#1086#1076#1080#1084#1099#1093' '#1076#1086#1082#1091#1084#1077#1085#1090#1086#1074
  Constraints.MinHeight = 555
  Constraints.MinWidth = 749
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  inherited sbBottom: TStatusBar
    Top = 501
    Width = 741
  end
  inherited Panel1: TPanel
    Width = 741
    Visible = False
    inherited BitBtn1: TBitBtn
      Left = 572
    end
    inherited BitBtn2: TBitBtn
      Left = 660
    end
  end
  object Panel2: TPanel [2]
    Left = 0
    Top = 45
    Width = 741
    Height = 456
    Align = alClient
    BevelInner = bvLowered
    TabOrder = 2
    object Panel5: TPanel
      Left = 325
      Top = 2
      Width = 414
      Height = 452
      Align = alClient
      BevelInner = bvLowered
      TabOrder = 0
      object Label1: TLabel
        Left = 13
        Top = 8
        Width = 217
        Height = 19
        Caption = #1053#1077#1086#1073#1093#1086#1076#1080#1084#1099#1077' '#1076#1086#1082#1091#1084#1077#1085#1090#1099
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clGray
        Font.Height = -16
        Font.Name = 'Tahoma'
        Font.Style = [fsBold]
        ParentFont = False
      end
      object ToolBar3: TToolBar
        Left = 570
        Top = 9
        Width = 79
        Height = 33
        Align = alCustom
        AutoSize = True
        BorderWidth = 2
        EdgeInner = esNone
        EdgeOuter = esNone
        Images = DMInv.ilActive
        TabOrder = 0
        Transparent = True
      end
      object cxGrid4: TcxGrid
        Left = 5
        Top = 32
        Width = 401
        Height = 412
        Align = alCustom
        Anchors = [akLeft, akTop, akRight, akBottom]
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clWindowText
        Font.Height = -13
        Font.Name = 'Tahoma'
        Font.Style = []
        ParentFont = False
        TabOrder = 1
        LookAndFeel.Kind = lfStandard
        object cxGridDBTableView4: TcxGridDBTableView
          NavigatorButtons.ConfirmDelete = False
          NavigatorButtons.First.Visible = True
          NavigatorButtons.PriorPage.Visible = True
          NavigatorButtons.Prior.Visible = True
          NavigatorButtons.Next.Visible = True
          NavigatorButtons.NextPage.Visible = True
          NavigatorButtons.Last.Visible = True
          NavigatorButtons.Insert.Visible = False
          NavigatorButtons.Append.Visible = False
          NavigatorButtons.Delete.Visible = False
          NavigatorButtons.Edit.Visible = False
          NavigatorButtons.Post.Visible = False
          NavigatorButtons.Cancel.Visible = False
          NavigatorButtons.Refresh.Visible = False
          NavigatorButtons.SaveBookmark.Visible = False
          NavigatorButtons.GotoBookmark.Visible = False
          NavigatorButtons.Filter.Visible = False
          DataController.DataSource = dsNeedDoc
          DataController.Filter.Active = True
          DataController.KeyFieldNames = 'SDID'
          DataController.Summary.DefaultGroupSummaryItems = <>
          DataController.Summary.FooterSummaryItems = <>
          DataController.Summary.SummaryGroups = <>
          OptionsBehavior.CellHints = True
          OptionsBehavior.IncSearch = True
          OptionsCustomize.ColumnFiltering = False
          OptionsData.CancelOnExit = False
          OptionsData.Deleting = False
          OptionsData.DeletingConfirmation = False
          OptionsData.Inserting = False
          OptionsView.NavigatorOffset = 10
          OptionsView.CellAutoHeight = True
          OptionsView.CellTextMaxLineCount = 1
          OptionsView.ColumnAutoWidth = True
          OptionsView.GroupByBox = False
          OptionsView.Indicator = True
          OptionsView.ShowColumnFilterButtons = sfbAlways
          Preview.Visible = True
          Styles.IncSearch = DMInv.cxKrasniyText
          Styles.Selection = DMInv.cxJoltiyFon
          Styles.Header = DMInv.cxSiniyText
          object cxGridDBTableView4SDNAME: TcxGridDBColumn
            Caption = #1044#1086#1082#1091#1084#1077#1085#1090
            DataBinding.FieldName = 'SDNAME'
            Options.Editing = False
            Width = 273
          end
          object cxGridDBTableView4IS_CHECKED: TcxGridDBColumn
            Caption = #1053#1091#1078#1077#1085'?'
            DataBinding.FieldName = 'RND'
            PropertiesClassName = 'TcxCheckBoxProperties'
            Properties.ValueChecked = 1
            Properties.ValueUnchecked = 0
            Properties.OnEditValueChanged = cxGridDBTableView4IS_CHECKEDPropertiesEditValueChanged
            Width = 59
          end
        end
        object cxGridLevel3: TcxGridLevel
          GridView = cxGridDBTableView4
        end
      end
    end
    object Panel3: TPanel
      Left = 2
      Top = 2
      Width = 323
      Height = 452
      Align = alLeft
      ParentBackground = False
      TabOrder = 1
      object Label7: TLabel
        Left = 13
        Top = 8
        Width = 164
        Height = 19
        Caption = #1057#1090#1072#1090#1091#1089' '#1089#1086#1090#1088#1091#1076#1085#1080#1082#1072':'
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clGray
        Font.Height = -16
        Font.Name = 'Tahoma'
        Font.Style = [fsBold]
        ParentFont = False
      end
      object dbTW: TdxDBTreeView
        Left = 8
        Top = 32
        Width = 305
        Height = 411
        ShowNodeHint = True
        RowSelect = True
        DataSource = dsSDDic
        DisplayField = 'SDNAME'
        ImageIndexField = 'SDID'
        KeyField = 'SDID'
        ListField = 'SDNAME'
        ParentField = 'SDPARID'
        RootValue = 28
        SeparatedSt = '-'
        RaiseOnError = True
        ReadOnly = True
        Indent = 19
        OnChanging = dbTWChanging
        OnChange = dbTWChange
        Align = alCustom
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clBlack
        Font.Height = -13
        Font.Name = 'Arial'
        Font.Style = []
        ParentColor = False
        Options = [trCanDBNavigate]
        SelectedIndex = 1
        TabOrder = 0
        ParentFont = False
        ParentShowHint = False
        ShowHint = False
        StateImages = DMInv.ilBJTree
      end
    end
  end
  object dsSDDic: TDataSource
    DataSet = qSDDic
    Left = 40
    Top = 352
  end
  object qSDDic: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    CachedUpdates = True
    SQL.Strings = (
      'SELECT t1.*, SD1.SDISDELETE'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID = 13101'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t '
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t1'
      'INNER JOIN SYS_DIC sd1 ON sd1.SDID = t1.sdid'
      'order by 3')
    UpdateObject = quSDDIC
    GeneratorField.Field = 'SDID'
    Left = 72
    Top = 352
    object qSDDicSDNAME: TIBStringField
      FieldName = 'SDNAME'
      ProviderFlags = []
      Size = 2303
    end
    object qSDDicSDID: TIntegerField
      FieldName = 'SDID'
      ProviderFlags = []
    end
    object qSDDicSDPARID: TIntegerField
      FieldName = 'SDPARID'
      ProviderFlags = []
    end
    object qSDDicSDISDELETE: TIntegerField
      FieldName = 'SDISDELETE'
      Origin = '"SYS_DIC"."SDISDELETE"'
    end
  end
  object dsNeedDoc: TDataSource
    DataSet = qNeedDoc
    Left = 104
    Top = 352
  end
  object qNeedDoc: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    CachedUpdates = True
    SQL.Strings = (
      'SELECT osn.*, snd.sdid1, IIF(sdid1 > 0, 1, 0) AS rnd'
      'FROM (SELECT t1.sdparid, t1.sdid, t1.sdname'
      
        '      FROM (WITH RECURSIVE tree (sdname, sdid, sdparid) AS (SELE' +
        'CT sd.sdname, sd.sdid, sd.sdparid'
      
        '                                                            FROM' +
        ' sys_dic sd'
      
        '                                                            WHER' +
        'E sd.sdparid = 2'
      
        '                                                            UNIO' +
        'N ALL'
      
        '                                                            SELE' +
        'CT sd1.sdname, sd1.sdid, sd1.sdparid'
      
        '                                                            FROM' +
        ' sys_dic sd1'
      
        '                                                            INNE' +
        'R JOIN tree t ON t.sdid = sd1.sdparid) SELECT sdname,'
      
        '                                                                ' +
        '                                              sdid,'
      
        '                                                                ' +
        '                                              sdparid'
      
        '                                                                ' +
        '                                       FROM tree t) AS t1) osn'
      'LEFT JOIN(SELECT *'
      '          FROM sys_needdoc'
      '          WHERE sdid1 = :pstat) snd ON snd.sdid2 = osn.sdid'
      'WHERE NOT EXISTS('
      'SELECT t1.sdparid, t1.sdid, t1.sdname'
      
        '      FROM (WITH RECURSIVE tree (sdname, sdid, sdparid) AS (SELE' +
        'CT sd.sdname, sd.sdid, sd.sdparid'
      
        '                                                            FROM' +
        ' sys_dic sd'
      
        '                                                            WHER' +
        'E sd.sdparid = osn.sdid'
      
        '                                                            UNIO' +
        'N ALL'
      
        '                                                            SELE' +
        'CT sd1.sdname, sd1.sdid, sd1.sdparid'
      
        '                                                            FROM' +
        ' sys_dic sd1'
      
        '                                                            INNE' +
        'R JOIN tree t ON t.sdid = sd1.sdparid) SELECT sdname,'
      
        '                                                                ' +
        '                                              sdid,'
      
        '                                                                ' +
        '                                              sdparid'
      
        '                                                                ' +
        '                                       FROM tree t) AS t1'
      ')')
    UpdateObject = quNeedDoc
    GeneratorField.Field = 'SDID'
    Left = 136
    Top = 352
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'pstat'
        ParamType = ptUnknown
      end>
    object qNeedDocSDID: TIntegerField
      FieldName = 'SDID'
      ProviderFlags = []
    end
    object qNeedDocSDPARID: TIntegerField
      FieldName = 'SDPARID'
      ProviderFlags = []
    end
    object qNeedDocSDNAME: TIBStringField
      FieldName = 'SDNAME'
      ProviderFlags = []
      Size = 255
    end
    object qNeedDocSDID1: TIntegerField
      FieldName = 'SDID1'
      Origin = '"SYS_NEEDDOC"."SDID1"'
    end
    object qNeedDocRND: TIntegerField
      FieldName = 'RND'
      ProviderFlags = []
    end
  end
  object quNeedDoc: TIBUpdateSQL
    RefreshSQL.Strings = (
      'Select '
      '  PID,'
      '  SDID,'
      '  PSUSERENTER,'
      '  PSTIMEENTER,'
      '  PSUSEREDIT,'
      '  PSTIMEEDIT'
      'from P_STATUS '
      'where'
      '  PID = :PID')
    ModifySQL.Strings = (
      'update P_STATUS'
      'set'
      '  PID = :PID,'
      '  PSTIMEEDIT = :PSTIMEEDIT,'
      '  PSTIMEENTER = :PSTIMEENTER,'
      '  PSUSEREDIT = :PSUSEREDIT,'
      '  PSUSERENTER = :PSUSERENTER,'
      '  SDID = :SDID'
      'where'
      '  PID = :OLD_PID')
    InsertSQL.Strings = (
      'insert into P_STATUS'
      '  (PID, PSTIMEEDIT, PSTIMEENTER, PSUSEREDIT, PSUSERENTER, SDID)'
      'values'
      
        '  (:PID, :PSTIMEEDIT, :PSTIMEENTER, :PSUSEREDIT, :PSUSERENTER, :' +
        'SDID)')
    DeleteSQL.Strings = (
      'null;')
    Left = 168
    Top = 352
  end
  object qInsNeedDoc: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    CachedUpdates = True
    SQL.Strings = (
      'execute procedure inssysneeddoc (:sdid1,:sdid2,:rnd,:gr)')
    GeneratorField.Field = 'SDID'
    Left = 136
    Top = 384
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'sdid1'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'sdid2'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'rnd'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'gr'
        ParamType = ptUnknown
      end>
  end
  object quSDDIC: TIBUpdateSQL
    RefreshSQL.Strings = (
      'Select '
      '  PID,'
      '  SCID'
      'from P_NEEDDOC '
      'where'
      '  PID = :PID')
    ModifySQL.Strings = (
      'update P_NEEDDOC'
      'set'
      '  PID = :PID,'
      '  SCID = :SCID'
      'where'
      '  PID = :OLD_PID')
    InsertSQL.Strings = (
      'insert into P_NEEDDOC'
      '  (PID, SCID)'
      'values'
      '  (:PID, :SCID)')
    DeleteSQL.Strings = (
      'delete from P_NEEDDOC'
      'where'
      '  PID = :OLD_PID')
    Left = 72
    Top = 384
  end
end
